        const themeToggle = document.getElementById('themeToggle');
        const isDarkMode = localStorage.getItem('darkMode') === 'true';
        
        if (isDarkMode) {
            document.body.classList.add('dark-mode');
            themeToggle.innerHTML = '<i class="fas fa-sun"></i>白天';
        }
        
        themeToggle.addEventListener('click', () => {
            document.body.classList.toggle('dark-mode');
            const isNowDarkMode = document.body.classList.contains('dark-mode');
            localStorage.setItem('darkMode', isNowDarkMode);
            
            if (isNowDarkMode) {
                themeToggle.innerHTML = '<i class="fas fa-sun"></i>白天';
            } else {
                themeToggle.innerHTML = '<i class="fas fa-moon"></i>黑夜';
            }
        });
        
        async function fetchQuote() {
            try {
                const response = await fetch('https://api.xyttkx.cn/gsc.php?type=json');
                const data = await response.json();
                
                if (data.content && data.poesy) {
                    document.getElementById('quoteText').textContent = data.content;
                    document.getElementById('quoteAuthor').textContent = `—— ${data.poesy}`;
                }
            } catch (error) {
                console.error('获取名言失败:', error);
                
                document.getElementById('quoteText').textContent = "只要过的开心，就不算虚度光阴。";
                document.getElementById('quoteAuthor').textContent = "—— 蔡同学";
            }
        }
        
        document.addEventListener('DOMContentLoaded', fetchQuote);
        
        const playBtn = document.getElementById('playBtn');
        const progressBar = document.getElementById('progressBar');
        const progressContainer = document.getElementById('progressContainer');
        const currentTimeEl = document.getElementById('currentTime');
        const totalTimeEl = document.getElementById('totalTime');
        const lyricsContainer = document.getElementById('lyricsContainer');
        const audioPlayer = document.getElementById('audioPlayer');
        
        const lyricsData = [
            { time: 16120, text: "像我这样优秀的人" },
            { time: 19860, text: "本该灿烂过一生" },
            { time: 23640, text: "怎么二十多年到头来" },
            { time: 27370, text: "还在人海里浮沉" },
            { time: 31270, text: "像我这样聪明的人" },
            { time: 35340, text: "早就告别了单纯" },
            { time: 39290, text: "怎么还是用了一段情" },
            { time: 43060, text: "去换一身伤痕" },
            { time: 46990, text: "像我这样迷茫的人" },
            { time: 50680, text: "像我这样寻找的人" },
            { time: 54870, text: "像我这样碌碌无为的人" },
            { time: 58890, text: "你还见过多少人" },
            { time: 79780, text: "像我这样庸俗的人" },
            { time: 83600, text: "从不喜欢装深沉" },
            { time: 87750, text: "怎么偶尔听到老歌时" },
            { time: 91520, text: "忽然也晃了神" },
            { time: 95270, text: "像我这样懦弱的人" },
            { time: 99070, text: "凡事都要留几分" },
            { time: 103130, text: "怎么曾经也会为了谁" },
            { time: 106790, text: "想过奋不顾身" },
            { time: 110860, text: "像我这样迷茫的人" },
            { time: 114700, text: "像我这样寻找的人" },
            { time: 118730, text: "像我这样碌碌无为的人" },
            { time: 122490, text: "你还见过多少人" },
            { time: 127130, text: "像我这样孤单的人" },
            { time: 130220, text: "像我这样傻的人" },
            { time: 134080, text: "像我这样不甘平凡的人" },
            { time: 137920, text: "世界上有多少人" },
            { time: 146400, text: "像我这样迷茫的人" },
            { time: 151510, text: "像我这样寻找的人" },
            { time: 155320, text: "像我这样碌碌无为的人" },
            { time: 159180, text: "你还见过多少人" },
            { time: 163080, text: "像我这样孤单的人" },
            { time: 166970, text: "像我这样傻的人" },
            { time: 171270, text: "像我这样不甘平凡的人" },
            { time: 174770, text: "世界上有多少人" },
            { time: 181090, text: "像我这样莫名其妙的人" },
            { time: 187640, text: "会不会有人心疼" }
        ];
        
        lyricsData.forEach((lyric, index) => {
            const lyricLine = document.createElement('div');
            lyricLine.className = 'lyric-line';
            lyricLine.id = `line-${index}`;
            lyricLine.textContent = lyric.text;
            lyricsContainer.appendChild(lyricLine);
        });
        
        let isPlaying = false;
        let currentLyricIndex = -1;
        
        function togglePlayback() {
            if (!isPlaying) {
                
                isPlaying = true;
                playBtn.innerHTML = '<i class="fas fa-pause"></i>';
                audioPlayer.play();
            } else {
                
                isPlaying = false;
                playBtn.innerHTML = '<i class="fas fa-play"></i>';
                audioPlayer.pause();
            }
        }
        
        function updateProgress() {
            const currentTime = audioPlayer.currentTime;
            const duration = audioPlayer.duration;
            const progress = (currentTime / duration) * 100;
            
            progressBar.style.width = `${progress}%`;
            
            const minutes = Math.floor(currentTime / 60);
            const seconds = Math.floor(currentTime % 60);
            currentTimeEl.textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
            
            syncLyrics(currentTime * 1000); 
            
            if (isPlaying) {
                requestAnimationFrame(updateProgress);
            }
        }
        
        
        function syncLyrics(currentTime) {
            
            let newIndex = -1;
            for (let i = 0; i < lyricsData.length; i++) {
                if (currentTime >= lyricsData[i].time) {
                    newIndex = i;
                } else {
                    break;
                }
            }
            
            if (newIndex !== currentLyricIndex) {
                currentLyricIndex = newIndex;
                
                const lyricLines = document.querySelectorAll('.lyric-line');
                lyricLines.forEach((line, index) => {
                    line.classList.remove('active', 'prev', 'next');
                    
                    if (index === currentLyricIndex) {
                        line.classList.add('active');
                    } else if (index === currentLyricIndex - 1) {
                        line.classList.add('prev');
                    } else if (index === currentLyricIndex + 1) {
                        line.classList.add('next');
                    }
                });
                
                if (currentLyricIndex >= 0) {
                    const currentLine = document.getElementById(`line-${currentLyricIndex}`);
                    if (currentLine) {
                        currentLine.scrollIntoView({
                            behavior: 'smooth',
                            block: 'center'
                        });
                    }
                }
            }
        }
        
document.addEventListener('DOMContentLoaded', function() {
    const progressBars = document.querySelectorAll('.skill-progress');
    
    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                const progressBar = entry.target;
                const percentage = progressBar.getAttribute('data-percentage');
                progressBar.style.width = `${percentage}%`;
                observer.unobserve(progressBar); 
            }
        });
    }, { threshold: 0.1 });
    
    progressBars.forEach(bar => {
        observer.observe(bar);
    });
});

        progressContainer.addEventListener('click', function(e) {
            const rect = this.getBoundingClientRect();
            const clickX = e.clientX - rect.left;
            const newProgress = clickX / rect.width;
            
            audioPlayer.currentTime = newProgress * audioPlayer.duration;
            
            progressBar.style.width = `${newProgress * 100}%`;
            
            syncLyrics(newProgress * audioPlayer.duration * 1000);
        });
        
        playBtn.addEventListener('click', togglePlayback);
        
        audioPlayer.addEventListener('loadedmetadata', function() {
            const duration = audioPlayer.duration;
            const minutes = Math.floor(duration / 60);
            const seconds = Math.floor(duration % 60);
            totalTimeEl.textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
        });
        
        audioPlayer.addEventListener('play', function() {
            updateProgress();
        });

        audioPlayer.addEventListener('pause', function() {
            isPlaying = false;
            playBtn.innerHTML = '<i class="fas fa-play"></i>';
        });